
#define RUNTIME_DBG_LVL 0
#define _GNU_SOURCE
#include <pthreadalt.h>

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <dbg.h>
#include <dbg/ptest.h>
// #include <ddblk/syslock.h>
#include <ddblk/locks.h>
#include <ddblk/locks2apds.h>
#include <ddblk/apds.h>
#include <ddblk/apds/delegation/rcl.h>
#include "dblk_test.h"
#include "dblk_perftest.h"

#define TEST_NR		(1000000)
#define TEST_THREADNR	(HDEF_NATIVE_CPU_NR)

static tstack_t apdstinfo_tlsstk;
static TLS_INITIAL apdstls_t *apdstinfo_tls;
DEF_APDSTINFO_TLS(&apdstinfo_tlsstk, &apdstinfo_tls, malloc, 4096, mp_coreid)
static TLS_INITIAL spobj_t *lknode_tls;
DEF_LOCKNODE_SPSLAB(splknode, &lknode_tls, HDEF_CACHE_LINE_BYTES, 16384)


/* rcl */
DEF_COMBINE(rcl, rcl, OUFUN_OF(apdstls), OUFUN_OF(schedyield_wait), OUFUN_OF(spslablknode))

DEF_TEST_TYPE(rcl, fetch_add, TEST_NR)

#include <pthreadalt/pthreadalt_init.h>
DEF_PTHREADALT_INIT
DEF_SYSINIT(apdstls)
DEF_CFLOWINIT(apdstls)
DEF_CFLOWFIN(apdstls, splknode)
DEF_SYSFIN(__omega)

int main(){
	test_rcl(TEST_THREADNR);
	printf("%lu\n", ptc);
	return 0;
}

